package com.casic.ops.entity.dto;


import com.casic.ops.entity.request.BatchUploadRequest;
import com.casic.ops.entity.request.sftp.FileUploadRequest;
import com.orion.utils.convert.TypeStore;
import lombok.Data;

import java.util.List;

/**
 * @ClassName ops-platform
 * @Description sftp 上传对象
 * @Author mianbin
 * @Date 2022/5/31 10:59
 * @Version 1.0
 **/
@Data
public class SftpUploadInfoDTO {

    /**
     * 远程路径
     */
    private String remotePath;

    /**
     * 机器id
     */
    private Long machineId;

    /**
     * 机器id
     */
    private List<Long> machineIdList;

    /**
     * 用户id
     */
    private Long userId;

    public static SftpUploadInfoDTO BatchUploadRequest2SftpUploadInfoDTO(BatchUploadRequest p) {
        SftpUploadInfoDTO dto = new SftpUploadInfoDTO();
        dto.setRemotePath(p.getRemotePath());
        dto.setMachineIdList(p.getMachineIds());
        return dto;
    }

    public static SftpUploadInfoDTO FileUploadRequest2SftpUploadInfoDTO(FileUploadRequest p) {
        SftpUploadInfoDTO dto = new SftpUploadInfoDTO();
        dto.setRemotePath(p.getRemotePath());
        return dto;
    }

    static {
        TypeStore.STORE.register(BatchUploadRequest.class, SftpUploadInfoDTO.class, p -> {
            SftpUploadInfoDTO dto = new SftpUploadInfoDTO();
            dto.setRemotePath(p.getRemotePath());
            dto.setMachineIdList(p.getMachineIds());
            return dto;
        });
        TypeStore.STORE.register(FileUploadRequest.class, SftpUploadInfoDTO.class, p -> {
            SftpUploadInfoDTO dto = new SftpUploadInfoDTO();
            dto.setRemotePath(p.getRemotePath());
            return dto;
        });
    }
}
